package com.atguigu.exam;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 4、在工程或module的src下有名为”jdbc.properties”的配置文件，
 * 文件内容为：name=Tom。如何在程序中通过代码获取Tom这个变量值。代码实现
 * @author xbd
 * @create 2021-06-01 17:11
 */
public class PropertiesTest {
    public static void main(String[] args) throws IOException {
        Properties properties = new Properties();
        ClassLoader classLoader = PropertiesTest.class.getClassLoader();
        InputStream is = classLoader.getResourceAsStream("jdbc.properties");
        properties.load(is);

        String name = properties.getProperty("name");
        System.out.println("name = " + name);

    }
}
